package comm.suger.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import comm.suger.web.model.entity.SysUser;
import comm.suger.web.service.impl.SysUserServiceImpl;
import comm.suger.web.utils.ResponseBean;

@Controller
public class LoginController extends BaseController{

	@Resource(name="sysUserService")
	private SysUserServiceImpl sysUserService;
	
	@RequestMapping(value="/login")
	public String loginview(HttpServletRequest request){
		
		return "/";
	}
	
	@RequestMapping(value ="/person/login", method= RequestMethod.POST)  
	public @ResponseBody Map login(@RequestBody SysUser sysUser ){
		
		String username =sysUser.getUname();
		String pwd = sysUser.getPasswd();
		Map<String , Object> map = new HashMap<String, Object>();
		if(username!=null){
			SysUser su =sysUserService.getUser(username, pwd);
			if(su!=null){
				map.put("status",1);
			}else{
				map.put("status",0);
				map.put("message", "用户名或者密码不对");
			}
		}
		return map;
	}
}
